<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
<head>
<!--
		Charisma v1.0.0

		Copyright 2012 Muhammad Usman
		Licensed under the Apache License v2.0
		http://www.apache.org/licenses/LICENSE-2.0

		http://usman.it
		http://twitter.com/halalit_usman
	-->
<meta charset="utf-8">
	<title>友宝后台管理系统</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description"
	content="Charisma, a fully featured, responsive, HTML5, Bootstrap admin template.">
<meta name="author" content="Muhammad Usman">

<!-- The styles -->
<link id="bs-css" href="css/bootstrap-cerulean.css" rel="stylesheet">
<style type="text/css">
body {
	padding-bottom: 40px;
}

.sidebar-nav {
	padding: 9px 0;
}
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/charisma-app.css" rel="stylesheet">
<link href="css/jquery-ui-1.8.21.custom.css" rel="stylesheet">
<link href='css/fullcalendar.css' rel='stylesheet'>
<link href='css/fullcalendar.print.css' rel='stylesheet' media='print'>
<link href='css/chosen.css' rel='stylesheet'>
<link href='css/uniform.default.css' rel='stylesheet'>
<link href='css/colorbox.css' rel='stylesheet'>
<link href='css/jquery.cleditor.css' rel='stylesheet'>
<link href='css/jquery.noty.css' rel='stylesheet'>
<link href='css/noty_theme_default.css' rel='stylesheet'>
<link href='css/elfinder.min.css' rel='stylesheet'>
<link href='css/elfinder.theme.css' rel='stylesheet'>
<link href='css/jquery.iphone.toggle.css' rel='stylesheet'>
<link href='css/opa-icons.css' rel='stylesheet'>
<link href='css/uploadify.css' rel='stylesheet'>

<!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
	  <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->

<!-- The fav icon -->
<link rel="shortcut icon" href="img/favicon.ico">

</head>

<body>
	<s:include value="header.jsp" />
	<!-- topbar ends -->
	<div class="container-fluid">
		<div class="row-fluid">

			<s:include value="left.jsp" />

			<div id="content" class="span10">
				<!-- content starts -->


				<div>
					<ul class="breadcrumb">
						<li><a href="index">主页</a> <span class="divider">/</span></li>
						<li><a href="#">终端信息</a></li>
					</ul>
				</div>
				<a href="addTerminal" class="btn btn-large"><i class="icon-download-alt"></i>新增终端</a>

				<div class=" row-fluid" style="margin-top:20px">
					<table
						class="table table-striped table-bordered bootstrap-datatable datatable">
						<thead>
							<tr role="row">
								<th class="sorting_asc" role="columnheader" tabindex="0"
									aria-controls="DataTables_Table_0" rowspan="1" colspan="1">ID</th>
								<th class="sorting" role="columnheader" tabindex="0"
									aria-controls="DataTables_Table_0" rowspan="1" colspan="1">网点名称</th>
								<th class="sorting" role="columnheader" tabindex="0"
									aria-controls="DataTables_Table_0" rowspan="1" colspan="1">终端名称</th>
								<th class="sorting" role="columnheader" tabindex="0"
									aria-controls="DataTables_Table_0" rowspan="1" colspan="1">登录时间</th>
								<th class="sorting" role="columnheader" tabindex="0"
									aria-controls="DataTables_Table_0" rowspan="1" colspan="1">操作</th>

							</tr>
						</thead>

						<tbody>
							<s:iterator value="terminals" status="st">
								<tr class="odd">
									<td><s:property value="terminalId" /></td>
									<td class="center "><s:property value="branch.branchName" /></td>
									<td class="center "><s:property value="name" /></td>
									<s:if test="status==1">
										<td class="center " style="background-color: #FF99FF"><s:date name="loginTime" format="yyyy-MM-dd HH:mm:ss"/></td>
									</s:if>
									<s:else>
										<td class="center "><s:date name="loginTime" format="yyyy-MM-dd HH:mm:ss"/></td>
									</s:else>
									<td class="center "> 
										<a href="getUntakenParcel!execute?terminalID=<s:property value="terminalId" />">
											剩余包裹
										</a>|
										<a href="goods!getUnTakenGoods?terminalID=<s:property value="terminalId" />">
											剩余物品
										</a>|
										<a href="boxList?terminalID=<s:property value="terminalId" />">
											箱子使用情况
										</a>|
										<a href="Terminals!getTerminalDetails?terminalID=<s:property value="terminalId" />">
											设备详情
										</a>|
										<a href="getTerminalById?terminalID=<s:property value="terminalId" />">
											修改
										</a>|
										<a href="deleteTerminal?terminalID=<s:property value="terminalId" />" onclick="return confirm('若有箱格处于占用状态则无法删除，是否继续？')">
											删除
										</a>|
										 <a href="javascript:void(0);" class="ctrlOpen" data-toggle="modal" data-target="#myModal" data-attr="<s:property value="terminalId" />">设备控制</a>
									</td>
								</tr>
							</s:iterator>
						</tbody>
					</table>
				</div>
				<!-- content ends -->
			</div>
			<!--/#content.span10-->
		</div>
		<!--/fluid-row-->

		<hr>

		<div class="modal hide fade" id="myModal">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal">×</button>
				<h3>设备控制面板</h3>
			</div>
			<div class="modal-body ctrlPannel" style="text-align: center;">
			
				<div class="alert alert-success prompt-info" style="display:none">
							<button type="button" class="close">×</button>
							<span id="ctrlMsg"></span>
				</div>
				
					<button class="btn btn-small btn-primary ctrlBtn" id="closeT" data-status="4">关机</button>
					<button class="btn btn-small btn-primary ctrlBtn" id="restartT" data-status="3">重启</button>
					<button class="btn btn-small btn-primary ctrlBtn" id="maintianT"data-status="5">维护</button>
					<button class="btn btn-small btn-primary ctrlBtn" id="recoverT" data-status="0">恢复</button>
					<button class="btn btn-small btn-primary ctrlBtn" id="collectT" data-status="12">采集</button>
			</div>
			<div class="modal-footer">
				<a href="#" class="btn" data-dismiss="modal">Close</a> 
			</div>
		</div>
		
		
	    <div class="modal hide fade" id="lookTerminalPwd">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal">X</button>
				<h3>查看设备密码</h3>
			</div>
			<div class="modal-body " id="terminaipwd">
			</div>
			<div class="modal-footer">
				<a href="#" class="btn" data-dismiss="modal">Close</a>
			</div>
		</div>

	<s:include value="footer.jsp" />

	</div>
	
	

	<!--/.fluid-container-->

	<!-- external javascript
	================================================== -->
	<!-- Placed at the end of the document so the pages load faster -->

	<!-- jQuery -->
	<script src="js/jquery-1.7.2.min.js"></script>
	<!-- jQuery UI -->
	<script src="js/jquery-ui-1.8.21.custom.min.js"></script>
	<!-- transition / effect library -->
	<script src="js/bootstrap-transition.js"></script>
	<!-- alert enhancer library -->
	<script src="js/bootstrap-alert.js"></script>
	<!-- modal / dialog library -->
	<script src="js/bootstrap-modal.js"></script>
	<!-- custom dropdown library -->
	<script src="js/bootstrap-dropdown.js"></script>
	<!-- scrolspy library -->
	<script src="js/bootstrap-scrollspy.js"></script>
	<!-- library for creating tabs -->
	<script src="js/bootstrap-tab.js"></script>
	<!-- library for advanced tooltip -->
	<script src="js/bootstrap-tooltip.js"></script>
	<!-- popover effect library -->
	<script src="js/bootstrap-popover.js"></script>
	<!-- button enhancer library -->
	<script src="js/bootstrap-button.js"></script>
	<!-- accordion library (optional, not used in demo) -->
	<script src="js/bootstrap-collapse.js"></script>
	<!-- carousel slideshow library (optional, not used in demo) -->
	<script src="js/bootstrap-carousel.js"></script>
	<!-- autocomplete library -->
	<script src="js/bootstrap-typeahead.js"></script>
	<!-- tour library -->
	<script src="js/bootstrap-tour.js"></script>
	<!-- library for cookie management -->
	<script src="js/jquery.cookie.js"></script>
	<!-- calander plugin -->
	<script src='js/fullcalendar.min.js'></script>
	<!-- data table plugin -->
	<script src='js/jquery.dataTables.min.js'></script>

	<!-- chart libraries start -->
	<script src="js/excanvas.js"></script>
	<script src="js/jquery.flot.min.js"></script>
	<script src="js/jquery.flot.pie.min.js"></script>
	<script src="js/jquery.flot.stack.js"></script>
	<script src="js/jquery.flot.resize.min.js"></script>
	<!-- chart libraries end -->

	<!-- select or dropdown enhancer -->
	<script src="js/jquery.chosen.min.js"></script>
	<!-- checkbox, radio, and file input styler -->
	<script src="js/jquery.uniform.min.js"></script>
	<!-- plugin for gallery image view -->
	<script src="js/jquery.colorbox.min.js"></script>
	<!-- rich text editor library -->
	<script src="js/jquery.cleditor.min.js"></script>
	<!-- notification plugin -->
	<script src="js/jquery.noty.js"></script>
	<!-- file manager library -->
	<script src="js/jquery.elfinder.min.js"></script>
	<!-- star rating plugin -->
	<script src="js/jquery.raty.min.js"></script>
	<!-- for iOS style toggle switch -->
	<script src="js/jquery.iphone.toggle.js"></script>
	<!-- autogrowing textarea plugin -->
	<script src="js/jquery.autogrow-textarea.js"></script>
	<!-- multiple file upload plugin -->
	<script src="js/jquery.uploadify-3.1.min.js"></script>
	<!-- history.js for cross-browser state change on ajax -->
	<script src="js/jquery.history.js"></script>
	<!-- application script for Charisma demo -->
	<script src="js/charisma.js"></script>
	<script type="text/javascript">
	$(".ctrlOpen").click(function(){
		var id=$(this).attr("data-attr");
		//console.log("id: "+id);
		$(".ctrlPannel").attr("data-id",id);
	});
	
	$(".ctrlBtn").click(function(){
		$(".prompt-info").hide();
		var url="http://112.124.59.126:8080/YouBoxApi/controller?funcID=0021&status="
				+$(this).attr("data-status")+
				"&terminalId="+$(".ctrlPannel").attr("data-id");
		//console.log("url: "+url);
		$.get(url,function(data){
			$(".prompt-info").show();
			if(data.result==0){
				$("#ctrlMsg").html("操作成功");
			}else{
				$("#ctrlMsg").html("操作失败");
			}
		});
	});
	$(".close").click(function(){
		//console.log("close!");
		$(".prompt-info").hide();
	});
	$(function(){
		var terminal="";
		$(".linkOfpwd").live("click",function(){
			terminal=$(this).attr("termainalid");
		});
		
		//窗口显示之前的事件
		$("#lookTerminalPwd").on('shown', function () {
	         $.post("Terminals!getTermainalPwd?terminalID="+terminal,function(v){
	        	// alert(v);
	            $("#terminaipwd").html(v);
	         });
		});
	});
	</script>

</body>
</html>
